import fetch from 'utils/fetch';

/**
 * 
 * @param {*} id 
 */
let get = (id)=>{
    return fetch({
        url: '/groups/'+id,
        method: 'get'
    });
}

/**
 *  params = {
        pageIndex:0,
        pageSize:20,
        ...
    }
 */
let list = (params)=>{
    return fetch({
        url: '/groups',
        method: 'get',
        params
    });
}

let create = (name)=>{
    const data = {
        name
    }
    return fetch({
        url: '/groups/create',
        method: 'post',
        data
    });
}

let rename = (id, name)=>{
    const data = {
        name
    }
    return fetch({
        url: '/groups/'+id+'/rename',
        method: 'post',
        data
    });
}

let del = (id)=>{
    return fetch({
        url: '/groups/'+id+'/delete',
        method: 'post',
    });
}

export default {
    get,
    list,
    create,
    rename,
    del
}